# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=rofimoji
pkgver=6.1.0
pkgrel=2
pkgdesc='Character picker for rofi'
arch=('any')
url=https://github.com/fdw/rofimoji
license=('MIT')
depends=('python-configargparse')
makedepends=('python-build' 'python-installer' 'python-poetry-core')
optdepends=('emoji-font: for the emojis character file'
            'nerd-fonts: for the nerd_font character file'
            'rofi: for the X.Org selector'
            'xclip: for one of the X.Org clipboarders'
            'xsel: for one of the X.Org clipboarders'
            'xdotool: for the X.Org typer'
            'wofi: for a Wayland selector'
            'fuzzel: for a Wayland selector'
            'wl-clipboard: for the Wayland clipboarder'
            'wtype: for the Wayland typer')
install=$pkgname.install
source=("https://files.pythonhosted.org/packages/source/${pkgname::1}/$pkgname/$pkgname-$pkgver.tar.gz")
sha256sums=('5af61a78905d7c66d7043b9f802cd40bd6e2f265bfaf43c54156405914cfa112')
b2sums=('7dd3aaa55d76d656571b31855f2d67fbcfc0e66e9fa6454a7ef3e02b8f2880b6f08fe3598a87c3fa00918994be88cc76b5b231b1abbd45aa1dbbfc8ff0076f3a')

prepare() {
  cd $pkgname-$pkgver
  # Remove include list https://github.com/pypa/wheel/issues/92
  sed -i '/^include =/,/]/d' pyproject.toml
}

build() {
  cd $pkgname-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 -t "$pkgdir"/usr/share/man/man1 src/picker/docs/$pkgname.1

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/$pkgname-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
